package test3;
import java.util.ArrayList;
public class ArrayListIntegerStack implements IntegerStack {
    ArrayList<Integer> arr=new ArrayList<Integer>();

    public ArrayListIntegerStack(int n) {
        ArrayList arr = new ArrayList<>();
    }
    @Override
    public Integer push(Integer item) {
        if(item==null)
        return null;
        else
            arr.add(item);
        return item;
    }

    @Override
    public Integer pop() {
        if(arr.size()==0){
            return null;
        }
        Object a =arr.get(arr.size()-1);
        arr.remove(arr.size()-1);
        return null;
    }

    @Override
    public Integer peek() {
        if(arr.size()==0){
            return null;
        }else {
            return arr.get(arr.size() - 1);
        }
    }

    @Override
    public boolean empty() {
        if(arr.size()==0)
            return true;
        else
        return false;
    }

    @Override
    public int size() {
        return arr.size();
    }
    public ArrayList<Integer> getArrayList(){
        return arr;
    }
    public String toString(){
        return arr.toString();
    }
}
